package cn.com.db.Jwt;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;

public class JWT {
    private Header header;
    private Payload payload;
    private String verify;
    private String token;

    public Header getHeader() {
        return header;
    }

    public void setHeader(Header header) {
        this.header = header;
    }

    public Payload getPayload() {
        return payload;
    }

    public void setPayload(Payload payload) {
        this.payload = payload;
    }

    public String getVerify() {
        return verify;
    }

    public void setVerify(String verify) {
        this.verify = verify;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    @Override
    public String toString() {
        return "JWT{" +
                "header=" + header +
                ", payload=" + payload +
                ", verify='" + verify + '\'' +
                '}';
    }

    public static void main(String[] args) {
        Header header=new Header();
        header.setAlg("alg");
        header.setType("type");
        Data data=new Data();
        data.setId("id");
        data.setEmail("email");
        data.setUnionid("unionid");
        Payload payload=new Payload();
        payload.setData(data);
        JWT jwt=new JWT();
        jwt.setHeader(header);
        jwt.setVerify("verify");
        jwt.setPayload(payload);
        String json=JSON.toJSONString(jwt);
        System.out.println(json);
        JWT j=JSON.parseObject(json,JWT.class, Feature.DisableCircularReferenceDetect);
        System.out.println(j.header.toString());
        System.out.println(j.payload.getData().toString());
    }
}




